<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-3.3.1.min.js"></script>
<style type="text/css">
	div{
		align-content: center;
		margin-left: 10px;
		margin-top: 10px;
		font-family: inherit;
	}
	a:link {
		font-size: 14px;
		color: #000000;
		text-decoration: none;
	}
	a:visited{
		color:#000000;
		text-decoration: none;
		
	}
	a:hover {
		color: white;
		text-decoration: underline;
	}  
	dd{
		padding-top: 8px;
	}
</style>
</head>
<body bgcolor="#999999">
<h4>菜单</h4>
<div id="left" align="left" style="margin-top:5px;height: 620px">

</div>
</body>
<script type="text/javascript">
	query();
	function query(){
		$.ajax({
			type:"post",//设置提交方式
			url:"${pageContext.request.contextPath}/FindMenuServlet",
			async:true,//表示进行异步执行
			dataType:"json",//数据的返回类型
			data:{
			},
			success:function(data){//data就是成功之后 Servlet返回的结果
				var str = "";
				for(var i = 0;i<data.length;i++){
					var item = data[i];
					str += "<div><a href='#' onclick='go("+item.menuLevel+")'>"+item.menuName+"</a></div>";
					str += "<div id="+item.menuLevel+"></div>"
				}
				$("#left").html(str);
			},
			error:function(err){
				alert("失败");
			}
		});
	}
	function go(menuLevel){
		var level = "00"+menuLevel;
		$.ajax({
			type:"post",//设置提交方式
			url:"${pageContext.request.contextPath}/FindDownMenuServlet",
			async:true,//表示进行异步执行
			dataType:"json",//数据的返回类型
			data:{
				menuLevel : level
				},
			success:function(data){//data就是成功之后 Servlet返回的结果
				var str = "";
				for(var i = 0;i<data.length;i++){
				var	url = "http://localhost:8080/permissionManage" + data[i].menuUrl;
					str += "<div><table><tr><td>--<a href="+url+" target='main'>"+data[i].menuName+"</a></td></div>";
				}
				$("#"+level).html(str);
			},
			error:function(err){
				alert("操作失败");
			}
		});
		$("#"+level).slideToggle("slow");
	}
</script>
</html>